If you are interested in QuickOPC-COM, your task will most certainly involve reading data from an OPC server. Here are a few steps that illustrate how to achieve that, using Visual Basic 6.0. The steps are similar if you are using other tools or a different programming language.
We will create a form that will read a float value from the OPC server when loaded, and immediately display the formatted value in the text box on the form.
Install QuickOPC. Make sure that you have selected an installation choice that includes COM development.
Start Visual Basic 6.0, and create new project, selecting “Standard EXE” project type.
Reference the components for OPC "Classic" client development:
from the menu, and in the list of available references, look for following items and check the boxes next to them:Then, press
.Note: If some of the QuickOPC the type libraries are not shown in the References list, use the
button to locate and select them manually. The type libraries are installed under the SDK\lib subdirectory under the QuickOPC installation folder. Sometimes, simply restarting the Visual Basic 6.0 helps.Place a Text Box onto the form’s surface. Keep the name Text1.
Add handler for the Load event of the form: Switch to Code View, and select the Form object and then its Load member. Visual Basic will add the handler’s skeleton as follows:
Write the event handler implementation. Add the following code to the body of Form_Load method:
Copy Code
|
|
---|---|
' Create EasyOPC-DA component Dim EasyDAClient As New EasyDAClient ' Read item value and display it Me.Text1 = EasyDAClient.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single") |
Build and run the application by selecting
from the menu, and observe the results. The text box on the form will be filled with a float value we have read from the OPC server.If you are using a tool that does not have a referencing mechanism similar to Visual basic, you may need to create the EasyOPC-DA component directly. To do so, use the tool’s mechanism to create instance of a COM object, passing it a ProgID string “OpcLabs.EasyOpc.DataAccess.EasyDAClient”.